package domain;
import java.util.LinkedHashSet;
import java.util.Set;

import aima.core.agent.Action;
import aima.core.search.framework.ActionsFunction;
import aima.core.util.datastructure.XYLocation;

public class PacmanActionsFunction implements ActionsFunction {

	@Override
	public Set<Action> actions(Object state) {

		Set<Action> actions = new LinkedHashSet<Action>();
		PacmanBoard board = (PacmanBoard) state;
		XYLocation pacmanLocation = board.getPacmanLocation();

		if (board.canMoveUp())
			actions.add(new PacmanAction(PacmanAction.MOVE_UP, pacmanLocation.up()));
		if (board.canMoveDown())
			actions.add(new PacmanAction(PacmanAction.MOVE_DOWN, pacmanLocation.down()));
		if (board.canMoveLeft())
			actions.add(new PacmanAction(PacmanAction.MOVE_LEFT, pacmanLocation.left()));
		if (board.canMoveRight())
			actions.add(new PacmanAction(PacmanAction.MOVE_RIGHT, pacmanLocation.right()));

		return actions;

	}

}
